package com.jcfk.eam.util.enums;


import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import com.jcfk.eam.util.bean.codeParse.CodeParse;
import com.jcfk.eam.util.bean.codeParse.MouldCodeParse;

public enum CodeParseEnu {

    MOULD_CODE("模具编码", new MouldCodeParse());

    private final String desc;

    private final CodeParse codeParse;

    CodeParseEnu(String desc,CodeParse codeParse) {
        this.desc = desc;
        this.codeParse = codeParse;
    }

    public CodeParse parse(String code) {
        return codeParse.parse(code);
    }

    public Boolean matcher(String code) {
        return codeParse.matcher(code);
    }
    public void matcherThrow(String code) {
        Assert.isTrue(codeParse.matcher(code), StrUtil.format("{}:{},格式不正确",this.desc,code));

    }
}
